#include "common.h"
#include "datacenter.h"

boost::shared_ptr<DataCenter> g_DataCenter;

DeviceCaptureAndSendAd* g_DeviceCaptureAndSend = NULL;

int g_MainWindowNo = 1;
int g_SlaveWindowNo = 3;

QString MapPath(QString fileName)
{
	return "map/"+fileName;
}

QString HumanReadableSize(long long size)
{
	static const char* suffix[] = {
		"B",
		"KB",
		"MB",
		"GB",
	};
	static int suffixSize = sizeof(suffix) / sizeof(char*);
	int suffixPos = 0;
	long long remain = size;
	long long lastRemain = remain;
	while(suffixPos < suffixSize - 1 && remain > 1024)
	{
//		long long division = remain / 1024;
//		long long divRemain = remain % 1024;
//		if(divRemain > 0)
//			remain = division + 1;
//		else
//			remain = division;
		lastRemain = remain;
		remain /= 1024;
		suffixPos++;
	}
	return QString::number(lastRemain/1024.0, 'g', 3) + suffix[suffixPos];
}
